home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
emulator
/
zxam spectrum
/
zxam_rexx
/
español
/
monitor.zxam
< prev
next >
Wrap
Text File
|
1995-07-31
|
7KB
|
275 lines
/* Este script es un mini-monitor de CM creado por Leonardo Cocaña Galán */
/* Montado a partir de varios de los ejemplos que acompañan el ZXAM, y */
/* con aportación propia, por supuesto! */
/* Con el tiempo será bastante mejorado... */
/* comprobamos si el emulador está presente */
address command
if ~show(ports,ZXAM_REXX) then do
requestchoice 'title "ZXAM Script error..." body "No encuentro el puerto del emulador!!" gadgets "AARGH!"'
exit
end
/* Almacenar el estado inicial del emulador */
running=zxamactrun() /* 1=en marcha */
zxamstop() /* lo paramos */
/* abrimos la ventana de salida */
if ~open('fichero','con:0/11/640/256/Ejemplo de uso de ZXAMDisassemble()','W') then exit
dir=zxamgetreg(pc)
call desambla(dir,16)
call registros()
bucle: /* debemos seguir? */
call print ('(S)eguir,(N)ewDir,Set(PC),(P)oke,P(E)ek,(R)un,')
dummy=writech('fichero','0a'x)
call print ('(T)race,Brea(K)Point,Re(L)oad,(B)asic,(Q)uit,(F)ind: ')
respuesta=input()
respuesta=upper(respuesta)
if (respuesta='S'|respuesta='') then do
call desambla(dir,16)
call registros ()
end
if respuesta='Q' then signal cleanup
if respuesta='N' then call newdir()
if respuesta='P' then call poke()
if respuesta='R' then do
zxamrun()
dir=zxamgetreg(pc)
call desambla(dir,16)
call registros()
end
if respuesta='L' then do
call reload
dir=zxamgetreg(pc)
call desambla(dir,16)
call registros()
end
if respuesta='B' then do
call listbasic
signal bucle
end
if respuesta='PC' then call setpc
if respuesta='F' then call Findblock
if respuesta='E' then call peek
if respuesta='T' then do
dummy=zxamtrace()
dir=zxamgetreg(pc)
call desambla(dir,16)
call registros()
end
if respuesta='K' then call breakpoint
signal bucle
Desambla:
Parse arg direccion,linias
do i=1 to linias
linea=zxamdisassemble(direccion,'d') /* desensambla en decimal */
dummy=writech('fichero',substr(linea,2))
dummy=writech('fichero','0a'x)
direccion=(direccion+left(linea,1)) /* suma bytes que ocupa la inst */
if direccion>65535 then direccion=direccion-65536
dir = direccion
end i
return
registros:
dummy=writech('fichero','0a'x)
dummy=writech('fichero','BC 'zxamgetreg(bc,h))
dummy=writech('fichero',' DE 'zxamgetreg(de,h))
dummy=writech('fichero',' HL 'zxamgetreg(hl,h))
dummy=writech('fichero'," BC' "zxamgetreg(bc2,h))
dummy=writech('fichero'," DE' "zxamgetreg(de2,h))
dummy=writech('fichero'," HL' "zxamgetreg(hl2,h))
dummy=writech('fichero','0a'x)
dummy=writech('fichero','IX 'zxamgetreg(ix,h))
dummy=writech('fichero',' IY 'zxamgetreg(iy,h))
dummy=writech('fichero',' SP 'zxamgetreg(sp,h))
dummy=writech('fichero',' PC 'zxamgetreg(pc,h))
dummy=writech('fichero',' I 'zxamgetreg('i',h))
dummy=writech('fichero',' R 'zxamgetreg(r,h))
dummy=writech('fichero','0a'x)
dummy=writech('fichero'," A "zxamgetreg(a,h))
dummy=writech('fichero'," F "zxamgetreg(f,h))
dummy=writech('fichero'," A' "zxamgetreg(a2,h))
dummy=writech('fichero'," F' "zxamgetreg(f2,h))
dummy=writech('fichero',' IM'zxamgetreg(im))
dummy=writech('fichero',' INT 'zxamgetreg(int))
dummy=writech('fichero','0a'x)
dummy=writech('fichero','0a'x)
dummy=writech('fichero','S Z - H - P/V N C')
dummy=writech('fichero','0a'x)
dummy=writech('fichero',bittst(d2c(zxamgetreg(f)),7))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),6))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),5))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),4))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),3))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),2))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),1))
dummy=writech('fichero',' 'bittst(d2c(zxamgetreg(f)),0))
dummy=writech('fichero','0a'x)
dummy=writech('fichero','0a'x)
return
cleanup:
dummy=close('fichero')
/* dejar el emulador como estaba */
if running=1 then zxamrun()
exit
newdir:
call print ('Dirección PC: ')
dir=input()
if (dir>65535 | dir<0) then signal newdir
call desambla(dir,16)
call registros()
return
peek:
call print ('PEEK: ')
pek=input()
if (dir>65535 | dir<0) then signal peek
call print (zxampeek(pek))
dummy=writech('fichero','0a'x)
return
poke:
call print ('POKE ')
pok=input()
if length(pok)<7 then signal error_long
dirpoke=left(pok,(lastpos(",",pok)-1))
valor=right(pok,(length(pok)-lastpos(',',pok)))
if (dirpoke<16384 | dirpoke>65535) then signal error_dir
if (valor<0 |valor>255) then signal error_val
zxampoke(dirpoke,valor)
return
Print:
parse arg texto
dummy=writech('fichero',texto)
return
Input:
return readln('fichero')
Reload:
zxamparseloaded(zxampploadfile(zxamjoinpathname(zxamactloadpath(),zxamactname())))
return
Listbasic:
/* este script saca el listado del BASIC presente en la memoria del */
/* Spectrum y lo graba como fichero */
/* debemos listar el BASIC. primero lo localizamos */
/* dir inicio del BASIC (variable PROG) */
baselist=zxamdpeek(23635)
/* longitud del programa BASIC (con variable VARS) */
endlist=zxamdpeek(23627)
/* calculamos tamaño */
longbasic=endlist-baselist
if longbasic=0 then do
requestchoice '>nil: title "ZXAM Script error..." body "No hay programa BASIC!!" gadgets "AARGH!"'
return
end
/* cogemos toda el area BASIC */
bloquebasic=zxamgetmem(baselist,endlist-baselist)
do forever
/* procesamos la linea */
/* imprimimos numero de linea */
numlinea=c2d(left(bloquebasic,2))
dummy=writech('fichero',' 'numlinea)
longline=c2d(reverse(substr(bloquebasic,3,2))) /* fomato invertido Z80 */
do i=5 to 4+longline /* para procesar los caracteres de la linea */
if substr(bloquebasic,i,1)='0e'x then do
i=i+5
iterate
end
dummy=writech('fichero',zxambasictoken(substr(bloquebasic,i,1)))
end i
dummy=writech('fichero','0a'x)
bloquebasic=right(bloquebasic,length(bloquebasic)-(longline+4))
if bloquebasic='' then break
end
return
Setpc:
call print ('PC :')
pcdir=input()
if (pcdir>65535 | pcdir<0) then signal setpc
zxamsetreg(pc,pcdir)
dir=zxamgetreg(pc)
call desambla(dir,16)
call registros()
return
Error_dir:
Call Print ('ERROR DIRECCION FUERA DE MARGEN (16384-65535)')
dummy=writech('fichero','0a'x)
Signal poke
Error_val:
Call print ('ERROR VALOR FUERA DE MARGEN (0-255)')
dummy=writech('fichero','0a'x)
Signal poke
Error_long:
Call print ('ERROR PARAMETROS INCORRECTO (POKE 60000,255)')
dummy=Writech('fichero','0a'x)
signal poke
error_noblock:
call print ('BLOQUE DE DATOS NO ENCONTRADO')
dummy=writech('fichero','0a'x)
return
Findblock:
direc=0
call print ('Inserte datos a buscar (hex):')
block=x2c(input())
bucle1:
call busca(direc)
if direc<=-1 then do
call error_noblock
return
end
call desambla(direc,3)
direc=dir
signal bucle1
return
busca:
parse arg comienzo
direc=zxamfindblock(comienzo,block)
return
breakpoint:
call print('Direccion Break Point: ')
break=input()
if (break<0 |break>65535) then signal breakpoint
zxambreakpoint(break)
return